<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/detail.css">
</head>
<body> 

<div class="basic">
	<h1>散标管理</h1>
	<form id="query" class="form-inline">
		<div class="form-group">
	      <input type="text" class="form-control" name="id" placeholder="请输入id">
	   	</div>
	   	<button type="button" onclick="queryProduct('${pageContext.request.contextPath }/back/product/queryById')" class="btn btn-primary">查询</button>
	</form>
	<div class="manage">
		<span>散标列表</span>
		<span>
			<button type="button" onclick="loadPage('${pageContext.request.contextPath }/back/product/addProduct?action=form')" class="btn btn-primary">添加散标</button>
		</span>
	</div>
	<table id="products" class="table table-striped">
		<thead>
			<tr>
				<td>散标编号</td>
				<td>散标名称</td>
				<td>散标总额</td>
				<td>年化率</td>
				<td>还款期限</td>
				<td>散标简介</td>
				<td>散标类型</td>
				<td>已购金额</td>
				<td>已购人数</td>
				<td>是否满额</td>
				<td>编辑</td>
				
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${productsList }" var="product">
			<tr>
				<td>${product.productid }</td> <%--这里必须要是 .属性名 --%>
				<td>${product.pname }</td>
				<td>${product.ppricetotal }</td>
				<td>${product.prate }%</td>
				<td>${product.ptimelimit }月</td>
				<td>${product.pdesc }</td>
			 	<td>
					<c:choose>
						<c:when test="${product.ptype == 1 }">到期还本息</c:when>
						<c:when test="${product.ptype == 2 }">每月还利息</c:when>
						<c:when test="${product.ptype == 3 }">每月还本利</c:when>
					</c:choose>	
				</td> 
				<td>${product.ppricecurrent }</td>
				<td>${product.ppeoplecurrent }</td>
				<td>
					<c:choose>
						<c:when test="${product.pisdone == false }">否</c:when>
						<c:otherwise>是</c:otherwise>
					</c:choose>	
				</td>
				<td>
					<a href="javascript:getProduct('${pageContext.request.contextPath }/back/product/queryById?id=${product.productid }')">修改</a>
					<a href="javascript:deleteProduct('${pageContext.request.contextPath }/back/product/delete?id=${product.productid }')">删除</a>
				</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="modal fade" id="changeMsg" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" 
               data-dismiss="modal" aria-hidden="true">
                  &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">修改散标信息</h4>
         </div>
         <div class="modal-body">
         	<form id="changeForm">
         		<div class="form-group">
			      <label for="firstname" class="col-sm-2 control-label">散标名称</label>
			      <div class="col-sm-10">
			         <input type="text" class="form-control" name="pname" placeholder="请输入散标名称">
			      </div>
			   	</div>
			   	<div class="form-group">
			      <label for="lastname" class="col-sm-2 control-label">散标总额</label>
			      <div class="col-sm-10">
			         <input type="text" class="form-control" name="ppricetotal" placeholder="请输入散标总额">
			      </div>
			   	</div>
			   	<div class="form-group">
			      <label for="lastname" class="col-sm-2 control-label">年化率</label>
			      <div class="col-sm-10">
			         <input type="text" class="form-control" name="prate" placeholder="请输入年化率">
			      </div>
			   	</div>
			   	<div class="form-group">
			      <label for="lastname" class="col-sm-2 control-label">还款期限</label>
			      <div class="col-sm-10">
			         <input type="text" class="form-control" name="ptimelimit" placeholder="请输入还款期限">
			      </div>
			   	</div>
			   	<div class="form-group">
			      <label for="lastname" class="col-sm-2 control-label">散标简介</label>
			      <div class="col-sm-10">
			         <input type="text" class="form-control" name="pdesc" placeholder="请输入散标简介">
			      </div>
			   	</div>
			   	<div class="form-group">
			      <label for="lastname" class="col-sm-2 control-label">散标类型</label>
			      <div class="col-sm-10">
			         <select name="ptype" class="form-control">
			         	<option value="1">到期还本息</option>
						<option value="2">每月还利息</option>
						<option value="3">每月还本利</option>
			         </select>
			      </div>
			   	</div>
			   	<input class="hidden" name="productid">
         	</form>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="updateProduct('${pageContext.request.contextPath}/back/product/update')" class="btn btn-primary">提交更改</button>
         </div>
      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
</body>
</html>